﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SlotManager : MonoBehaviour
{

    public int rowCount = 10;
    public float rowSpace = 1f;
    public Vector2 pivotLeft = new Vector2(-1f, 0f);
    public Vector2 pivotRight = new Vector2(1f, 0f);
    
    public List<Slot> slotsLeft;
    public List<Slot> slotsRight;

    public GameObject slotPrefab;
    // Start is called before the first frame update
    void Awake()
    {
        GenerateSlots();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void GenerateSlots()
    {
        slotsLeft = new List<Slot>();
        for (int i = 0; i < rowCount; i++)
        {
            Vector2 slotLoc = pivotLeft + rowSpace * i * Vector2.up;
            Slot slot = MakeSlot(slotLoc);
            slotsLeft.Add(slot);
        }
        
        slotsRight = new List<Slot>();
        for (int i = 0; i < rowCount; i++)
        {
            Vector2 slotLoc = pivotRight + rowSpace * i * Vector2.up;
            Slot slot = MakeSlot(slotLoc);
            slotsRight.Add(slot);
        }
    }

    public Slot MakeSlot(Vector2 loc)
    {
        GameObject obj = Instantiate(slotPrefab, loc, Quaternion.identity, transform);
        return obj.GetComponent<Slot>();
    }
}
